#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 1e5+10;
int a[N];
void solve()
{
	 int sum = 0;
     int n; cin>>n;
     for(int i = 1; i<=n; i++) cin>>a[i];
     for(int i = 1; i<=n; i++)
     {
	     sum+= a[i]*(a[i]+4);	
	 }
	 cout<<sum + 10<<endl;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int t ;
	cin >> t;
	while(t--) solve();
	return 0;
}

